package com.sinosoft.system.primary.biz.imp;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sinosoft.system.primary.biz.SysUserRoleBiz;
import com.sinosoft.system.primary.dao.SysUserRoleDao;
import com.sinosoft.system.primary.entity.SysUserRole;
import com.sinosoft.system.util.page.Pagenation;

@Service
@Transactional
public class SysUserRoleBizImp implements SysUserRoleBiz{

	private static Logger log = Logger.getLogger(SysUserRoleBizImp.class);
	
	@Autowired
	private SysUserRoleDao sysUserRoleDao;
	
	@Override
	public int insertSysUserRole(SysUserRole sysUserRole) {
		log.info("新增SysUserRole数据"+sysUserRole.toString());
		return sysUserRoleDao.insertSysUserRole(sysUserRole);
	}

	@Override
	public int updateSysUserRole(SysUserRole sysUserRole) {
		log.info("更新SysUserRole数据"+sysUserRole.toString());
		return sysUserRoleDao.updateSysUserRole(sysUserRole);
	}

	@Override
	public int deleteSysUserRole(int id) {
		log.info("删除SysUserRole数据 id="+id);
		return sysUserRoleDao.deleteSysUserRole(id);
	}

	@Override
	public SysUserRole selectSysUserRole(int id) {
		log.info("根据ID查询SysUserRole数据 id="+id);
		return sysUserRoleDao.selectSysUserRole(id);
	}

	@Override
	public SysUserRole selectSysUserRole(List<String> queryKeys,List<Object> queryValues) {
		log.info("查询SysUserRole数据 ");
		return sysUserRoleDao.selectSysUserRole(queryKeys, queryValues);
	}

	@Override
	public int selectCountSysUserRole() {
		log.info("查询SysUserRole数据 总数量");
		return sysUserRoleDao.selectCountSysUserRole();
	}

	@Override
	public int selectCountSysUserRole(List<String> queryKeys,List<Object> queryValues) {
		log.info("查询SysUserRole数据 总数量"+queryKeys.toString());
		return sysUserRoleDao.selectCountSysUserRole(queryKeys, queryValues);
	}

	@Override
	public List<SysUserRole> selectLimitSysUserRole(int start, int size) {
		log.info("查询SysUserRole数据 limit数量:start="+start+",size="+size);
		return sysUserRoleDao.selectLimitSysUserRole(start, size);
	}

	@Override
	public List<SysUserRole> selectLimitSysUserRole(List<String> queryKeys,List<Object> queryValues,int start, int size) {
		log.info("条件查询SysUserRole数据数量");
		return sysUserRoleDao.selectLimitSysUserRole(queryKeys, queryValues, start,  size);
	}

	@Override
	public List<SysUserRole> selectAllSysUserRole() {
		log.info("查询所有SysUserRole数据");
		return sysUserRoleDao.selectAllSysUserRole();
	}

	@Override
	public List<SysUserRole> selectAllSysUserRole(List<String> queryKeys,List<Object> queryValues) {
		log.info("条件查询所有SysUserRole数据");
		return sysUserRoleDao.selectAllSysUserRole(queryKeys, queryValues);
	}

	@Override
	public Pagenation selectPageSysUserRole(Pagenation page) {
		log.info("分页查询所有SysUserRole数据");
		int start =	page.getStartRow();
		int size = page.getPageSize();
		List<SysUserRole> rows = sysUserRoleDao.selectLimitSysUserRole(page.getQueryKeys(), page.getQueryValues(),start,size);
		int total = sysUserRoleDao.selectCountSysUserRole(page.getQueryKeys(), page.getQueryValues());
		page.setTotal(total);
		page.setRows(rows);
		return page;
	}

	public SysUserRoleDao getSysUserRoleDao() {
		return sysUserRoleDao;
	}

	public void setSysUserRoleDao(SysUserRoleDao sysUserRoleDao) {
		this.sysUserRoleDao = sysUserRoleDao;
	}

}
